// Copyright 2009 Jan Hosang <jan.hosang@gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
    "flag"
    
    "gb/recipes"
    parser "gb/gbparser"
    "gb/invocation"
    "gb/depgraph"
)

var help *bool = flag.Bool("h", false, "display this usage")
var scan *bool = flag.Bool("scan", false, "only output the detected build targets, do nothing else")

func main() {
    flag.Parse()
    
    if *help {
        flag.Usage()
        return
    }
    
    depGraph := depgraph.New()
    for _, buildfile := range flag.Args() {
        recipes := recipes.New()
        finvocations, frecipes := parser.ParseBuildFile(buildfile)
        recipes.AddRecipes(frecipes)
        for finv := range finvocations.Iter() {
            recipes.Invoke(finv.(*invocation.Invocation), depGraph)
        }
    }
    
}
